package com.linsen.erp.admin.controller;


import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.linsen.core.common.enums.DeleteType;
import com.linsen.core.common.util.ConvertUtil;
import com.linsen.core.common.util.Result;
import com.linsen.core.log.annotation.Log;
import com.linsen.erp.admin.entity.EmployeeEntity;
import com.linsen.erp.admin.provider.dto.EmployeeDTO;
import com.linsen.erp.admin.provider.qo.EmployeeQo;
import com.linsen.erp.admin.provider.vo.EmployeeVO;
import com.linsen.erp.admin.service.IEmployeeService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;

import java.util.List;

/**
 * <p>
 * 员工-基本信息 前端控制器
 * </p>
 *
 * @author zhaoyong
 * @since 2024-10-08
 */
@RestController
@RequestMapping("/admin/employee")
@Api(tags = "员工管理")
@RequiredArgsConstructor
public class EmployeeController {
    private final IEmployeeService iEmployeeService;

    //@SaCheckPermission("admin:employee:page")
    @PostMapping("/page")
    @ApiOperation(value = "分页查询",response = EmployeeVO.class)
    public Result page(@RequestBody EmployeeQo employeeQo) {
        return Result.data(this.iEmployeeService.page(employeeQo));
    }

    @GetMapping("info")
    @ApiImplicitParam(name = "id", value = "员工id", required = true, dataType = "string")
    @ApiOperation(value = "员工详情",response = EmployeeVO.class)
    public Result get(@ApiIgnore @RequestParam(value = "id") String id) {
        return Result.data(this.iEmployeeService.get(id));
    }

    //@SaCheckPermission("admin:employee:save")
    @Log(value = "新增员工")
    @PostMapping("save")
    @ApiOperation("新增员工")
    public Result save(@RequestBody EmployeeDTO employeeDTO) {
        iEmployeeService.saveEmployee(employeeDTO);

        return Result.ok();
    }

    //@SaCheckPermission("admin:employee:update")
    @Log(value = "修改员工")
    @PostMapping("update")
    @ApiOperation("修改员工")
    public Result update(@RequestBody EmployeeDTO employeeDTO) {
        iEmployeeService.updateEmployee(employeeDTO);

        return Result.ok();
    }

    //@SaCheckPermission("admin:employee:delete")
    @Log(value = "删除员工")
    @PostMapping("delete")
    @ApiImplicitParam(name = "id", value = "员工id", required = true, dataType = "string")
    @ApiOperation("删除员工")
    public Result delete(@ApiIgnore @RequestParam("id") String id) {
        iEmployeeService.delete(id);

        return Result.ok();
    }
}
